About 856 letters
About 4 minutes
Description: Type conversion to bool
.
def bool(x):
'''
Type conversion to bool
:param x: A variable
:return: The value converted to bool
'''
The following values are converted to False
:
None
int
, float
__bool__
method returns False
__len__
method returns 0 Example:
print("0 is", bool(0))
print("10 is", bool(10))
print("'hello world' is", bool('hello world'))
print("'' is", bool(''))
print("None is", bool(None))
Created in 5/15/2025
Updated in 5/16/2025